package com.单例模式;

import java.lang.reflect.Constructor;

// 枚举
public enum  EnumSingle {
    INSTANCE;

    public EnumSingle getInstance() {
        return INSTANCE;
    }
}

class Test {
    public static void main(String[] args) throws Exception {
        EnumSingle instance1 = EnumSingle.INSTANCE;
        Constructor<EnumSingle> declaredConstructor = EnumSingle.class.getDeclaredConstructor(String.class, int.class);
        declaredConstructor.setAccessible(true);
        EnumSingle instance2 = declaredConstructor.newInstance();

        // java.lang.NoSuchMethodException: com.单例模式.EnumSingle.<init>()
        System.out.println(instance1);
        System.out.println(instance2);
    }
}
